#include <iostream>
#include <vector>
using namespace std;
class Move
{
public:

    Move(int i){
        _i = new int(i);
        cout<<"Move(int *i= NULL)"<<endl;//默认构造函数，没有传参也会被调用
    }
    ~Move()
    {
        cout<<"~Move()"<<endl;
        if (_i !=NULL)
        {
            delete _i;
        }
    }
    Move(const Move & another)
    {
        cout<<"Move(const Move & another)"<<endl;
        _i = new int;
        *_i = *another._i;
    }
    Move & operator =(const Move & another)
    {
        cout<<"A & operator =(const Move & another)"<<endl;
        if(this != &another)
        {
            delete _i;
            _i = new int;
            *_i = *another._i;
        }
    }
    Move(Move && another)
    {
        cout<<"Move(Move && another)"<<endl;
        _i = another._i;
        another._i = nullptr;
    }
    Move & operator =(Move && another)
    {
        cout<<"Move & operator =(Move && another)"<<endl;
        if(this != &another)
        {
            delete _i;
            _i = another._i;
            another._i = nullptr;
        }
    }

    int *_i;
};
int main()
{
    vector<Move> vm;
    vm.reserve(10);
    for (int i = 0; i < 3; ++i) {
        vm.push_back(Move(i));
    }

    vm.insert(vm.begin(),Move(100));

    return 0;
}
